#include <iostream>
#include <vector>

int Array[] = {3, 5, 1, 8, 4, 7, 6, 9, 0, 2};

void insertSort(int arr[], int arrsize)
{
    for(int i = 1; i < arrsize; i++)
    {
        int tempElement = arr[i];
        int j = i - 1;
        while(j >= 0 && arr[j] > tempElement)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = tempElement;
    }
}

std::vector<int> VectorArray = {3, 5, 1, 8, 4, 7, 6, 9, 0, 2};

void insertSort(std::vector<int>& arr)
{
    for(int i = 1; i < arr.size(); i++)
    {
        int tempElement = arr[i];
        int j = i - 1;
        while(j >= 0 && arr[j] > tempElement)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = tempElement;
    }
}

int main(void)
{
    int size = sizeof(Array) / sizeof(Array[0]);

    std::cout <<"Before Sort:" << std::endl;
    for(int i = 0; i < size; i++)
    {
        std::cout << Array[i] << " ";
    }
    std::cout << std::endl;

    insertSort(Array, size);

    std::cout <<"After Sort:" << std::endl;
    for(int i = 0; i < size; i++)
    {
        std::cout << Array[i] << " ";
    }
    std::cout << std::endl;

    std::cout <<"-------------------------------" << std::endl;
    

    std::cout <<"Before Sort:" << std::endl;
    for(int i = 0; i < VectorArray.size(); i++)
    {
        std::cout << VectorArray[i] << " ";
    }
    std::cout << std::endl;

    insertSort(VectorArray);

    std::cout <<"After Sort:" << std::endl;
    for(int i = 0; i < VectorArray.size(); i++)
    {
        std::cout << VectorArray[i] << " ";
    }
    
    return 0;
}
